<?php
class Member extends CI_Model
{
	public $tbl_name = 'user';
	public $col_username = 'username';
	public $col_password = 'password';
	private $col_joindate = 'joindate';

	public function __contruct()
	{
		parent::__construct();	
	}

	// public function add_status($content, $address, $userID)
	public function add($ref)
	{		
		$ip = $_SERVER['REMOTE_ADDR'];
		$port = $_SERVER['REMOTE_PORT'];
		$useragent = $_SERVER['HTTP_USER_AGENT'];

		$data = array(
			'firstname' => $this->input->post('first'),
			'lastname'  => $this->input->post('last'),
			'username'  => $this->input->post('username'),
			'password'  => $this->input->post('password'),
			'birthday'  => date("Y-m-d", strtotime($this->input->post('birthday'))),
			'email'     => $this->input->post('email'),
			$this->col_joindate  => date('Y-m-d H:i:s'),
			'address'   => $this->input->post('billingAddress1'),
			'city'      => $this->input->post('billingCity'),
			'state'     => $this->input->post('billingState'),
			'country'   => $this->input->post('billingCountry'),
			'paypal' 	=> $this->input->post('cust2'),
			'ip' 		=> $ip,
			'port' 		=> $port,
			'useragent' => $useragent,
			'ref' 		=> $ref
			);

		/* SESSION */
		$this->session->set_userdata('isLoggedIn', true);
		$this->session->set_userdata('username', $this->input->post('username'));
		$this->session->set_userdata('countryId', $this->input->post('billingCountry'));

		return $this->db->insert($this->tbl_name, $data);
	}
}
?>